﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyPS.Models;
using MyPSDALayer;

namespace MyPS.Controllers
{
    public class DecorateTaobaoController : Controller
    {
        MyPSEntities db = new MyPSEntities();
        //
        // GET: /DecorateTaobao /

        public ActionResult Index()
        {
            DTaobaoModel model = new DTaobaoModel();
            model.DailyList = db.Articles.Where(o => o.ISTaobao == "Y").OrderByDescending(o => o.CreateDate).Take(8).Select(o => new V_Name_ID { ID = o.ArticleID, Name = o.ArticleName }).ToList();
            model.TopList = db.Articles.Where(o => o.ISHot == "Y").OrderByDescending(o => o.CreateDate).Take(8).Select(o => new V_Name_ID { ID = o.ArticleID, Name = o.ArticleName }).ToList();
            return View(model);
        }

        public ActionResult Details(int id = 0)
        {
            var mode = db.CaseBases.Find(id);
            if (mode == null)
            {
                return HttpNotFound();
            }
            DTaobaoModel d_model = new DTaobaoModel();
            d_model.Case = mode;
            d_model.DailyList = db.Articles.Where(o => o.ISTaobao == "Y").OrderByDescending(o => o.CreateDate).Take(8).Select(o => new V_Name_ID { ID = o.ArticleID, Name = o.ArticleName }).ToList();
            d_model.TopList = db.Articles.Where(o => o.ISHot == "Y").OrderByDescending(o => o.CreateDate).Take(8).Select(o => new V_Name_ID { ID = o.ArticleID, Name = o.ArticleName }).ToList();
            return View(mode);
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }


    }
}
